package me.luger.core.auth.identity;

import me.luger.core.auth.cookie.util.CookieAuthUtil;
import me.luger.core.commom.util.ServletUtil;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

/**
 * Created by a on 2017/6/29.
 */
public class SimpleUserInfoGetter implements UserInfoGetter {
    @Override
    public SimpleUserInfo getUserInfo() {
        HttpServletRequest request = ServletUtil.getRequest();
        Map<String,String> cookieMap = CookieAuthUtil.getAuthCookie(request);

        SimpleUserInfo userInfo = null;
        if(null != cookieMap){
            userInfo = new SimpleUserInfo();
            userInfo.setUid(cookieMap.get("uid"));
        }
        return userInfo;
    }
}
